package com.gmail.liulijuan;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;



public class HashMapVSHashTable {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//1 zhangshan
		//2 lisi
		//3 wangwu
		Map map=new HashMap();
		String a;
		
		//add
		map.put(1, "zhangsan");
		map.put(2, "lisi");
		map.put(3,"wangwu");
		
		//del
		map.remove(1);
		
		
		//update
		map.put(1,"zhangsan2");
		
		
		//find
		if(map.containsKey(1))a=(String)map.get(1);
		
		
		//iterate keyset
		Set set=map.entrySet();
		Iterator iterator=set.iterator();
		while(iterator.hasNext()){
			Map.Entry me=(Map.Entry)iterator.next();
		System.out.println(me.getKey()+"/"+me.getValue());
		  
		}
		
		Hashtable ht=new Hashtable();
		String b;
		
		//add
		ht.put(1, "zhangsan");
		ht.put(2, "lisi");
		ht.put(3,"wangwu");
		
		//del
		ht.remove(1);
		
		
		//update
		ht.put(1,"zhangsan2");
		
		
		//find
		if(ht.containsKey(1))b=(String)ht.get(1);
		
		
		//iterate keyset
		Set setht=ht.entrySet();
		Iterator iteratorht=setht.iterator();
		while(iteratorht.hasNext()){
			Entry entry=(Entry)iteratorht.next();
		System.out.println(entry.getKey()+"/"+entry.getValue());
		  
		}
		
	

	}

}
